{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7ecc7207",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:16:24.325437Z",
     "start_time": "2021-09-17T06:16:19.428319Z"
    }
   },
   "outputs": [],
   "source": [
    "from autogluon.tabular import TabularDataset, TabularPredictor"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "3206b339",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:16:24.332861Z",
     "start_time": "2021-09-17T06:16:24.328537Z"
    }
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    }
   ],
   "source": [
    "data_name = 'stumbleupon'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4a392ef1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:16:24.351511Z",
     "start_time": "2021-09-17T06:16:24.335846Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['sample_submission.csv', 'train.csv', 'test.csv']"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.listdir(f'../autox/data/{data_name}')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6bc8546b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:16:27.795810Z",
     "start_time": "2021-09-17T06:16:27.530947Z"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "train_data = TabularDataset(f'../autox/data/{data_name}/train.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "21370fd8",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:16:28.084910Z",
     "start_time": "2021-09-17T06:16:28.079220Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(7395, 27)"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4ba99057",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:16:28.729627Z",
     "start_time": "2021-09-17T06:16:28.675663Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>url</th>\n",
       "      <th>urlid</th>\n",
       "      <th>boilerplate</th>\n",
       "      <th>alchemy_category</th>\n",
       "      <th>alchemy_category_score</th>\n",
       "      <th>avglinksize</th>\n",
       "      <th>commonlinkratio_1</th>\n",
       "      <th>commonlinkratio_2</th>\n",
       "      <th>commonlinkratio_3</th>\n",
       "      <th>commonlinkratio_4</th>\n",
       "      <th>...</th>\n",
       "      <th>is_news</th>\n",
       "      <th>lengthyLinkDomain</th>\n",
       "      <th>linkwordscore</th>\n",
       "      <th>news_front_page</th>\n",
       "      <th>non_markup_alphanum_characters</th>\n",
       "      <th>numberOfLinks</th>\n",
       "      <th>numwords_in_url</th>\n",
       "      <th>parametrizedLinkRatio</th>\n",
       "      <th>spelling_errors_ratio</th>\n",
       "      <th>label</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>http://www.bloomberg.com/news/2010-12-23/ibm-p...</td>\n",
       "      <td>4042</td>\n",
       "      <td>{\"title\":\"IBM Sees Holographic Calls Air Breat...</td>\n",
       "      <td>business</td>\n",
       "      <td>0.789131</td>\n",
       "      <td>2.055556</td>\n",
       "      <td>0.676471</td>\n",
       "      <td>0.205882</td>\n",
       "      <td>0.047059</td>\n",
       "      <td>0.023529</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>24</td>\n",
       "      <td>0</td>\n",
       "      <td>5424</td>\n",
       "      <td>170</td>\n",
       "      <td>8</td>\n",
       "      <td>0.152941</td>\n",
       "      <td>0.079130</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>http://www.popsci.com/technology/article/2012-...</td>\n",
       "      <td>8471</td>\n",
       "      <td>{\"title\":\"The Fully Electronic Futuristic Star...</td>\n",
       "      <td>recreation</td>\n",
       "      <td>0.574147</td>\n",
       "      <td>3.677966</td>\n",
       "      <td>0.508021</td>\n",
       "      <td>0.288770</td>\n",
       "      <td>0.213904</td>\n",
       "      <td>0.144385</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "      <td>0</td>\n",
       "      <td>4973</td>\n",
       "      <td>187</td>\n",
       "      <td>9</td>\n",
       "      <td>0.181818</td>\n",
       "      <td>0.125448</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>http://www.menshealth.com/health/flu-fighting-...</td>\n",
       "      <td>1164</td>\n",
       "      <td>{\"title\":\"Fruits that Fight the Flu fruits tha...</td>\n",
       "      <td>health</td>\n",
       "      <td>0.996526</td>\n",
       "      <td>2.382883</td>\n",
       "      <td>0.562016</td>\n",
       "      <td>0.321705</td>\n",
       "      <td>0.120155</td>\n",
       "      <td>0.042636</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>55</td>\n",
       "      <td>0</td>\n",
       "      <td>2240</td>\n",
       "      <td>258</td>\n",
       "      <td>11</td>\n",
       "      <td>0.166667</td>\n",
       "      <td>0.057613</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>http://www.dumblittleman.com/2007/12/10-foolpr...</td>\n",
       "      <td>6684</td>\n",
       "      <td>{\"title\":\"10 Foolproof Tips for Better Sleep \"...</td>\n",
       "      <td>health</td>\n",
       "      <td>0.801248</td>\n",
       "      <td>1.543103</td>\n",
       "      <td>0.400000</td>\n",
       "      <td>0.100000</td>\n",
       "      <td>0.016667</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>24</td>\n",
       "      <td>0</td>\n",
       "      <td>2737</td>\n",
       "      <td>120</td>\n",
       "      <td>5</td>\n",
       "      <td>0.041667</td>\n",
       "      <td>0.100858</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>http://bleacherreport.com/articles/1205138-the...</td>\n",
       "      <td>9006</td>\n",
       "      <td>{\"title\":\"The 50 Coolest Jerseys You Didn t Kn...</td>\n",
       "      <td>sports</td>\n",
       "      <td>0.719157</td>\n",
       "      <td>2.676471</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.222222</td>\n",
       "      <td>0.123457</td>\n",
       "      <td>0.043210</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>14</td>\n",
       "      <td>0</td>\n",
       "      <td>12032</td>\n",
       "      <td>162</td>\n",
       "      <td>10</td>\n",
       "      <td>0.098765</td>\n",
       "      <td>0.082569</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 27 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                 url  urlid  \\\n",
       "0  http://www.bloomberg.com/news/2010-12-23/ibm-p...   4042   \n",
       "1  http://www.popsci.com/technology/article/2012-...   8471   \n",
       "2  http://www.menshealth.com/health/flu-fighting-...   1164   \n",
       "3  http://www.dumblittleman.com/2007/12/10-foolpr...   6684   \n",
       "4  http://bleacherreport.com/articles/1205138-the...   9006   \n",
       "\n",
       "                                         boilerplate alchemy_category  \\\n",
       "0  {\"title\":\"IBM Sees Holographic Calls Air Breat...         business   \n",
       "1  {\"title\":\"The Fully Electronic Futuristic Star...       recreation   \n",
       "2  {\"title\":\"Fruits that Fight the Flu fruits tha...           health   \n",
       "3  {\"title\":\"10 Foolproof Tips for Better Sleep \"...           health   \n",
       "4  {\"title\":\"The 50 Coolest Jerseys You Didn t Kn...           sports   \n",
       "\n",
       "   alchemy_category_score  avglinksize  commonlinkratio_1  commonlinkratio_2  \\\n",
       "0                0.789131     2.055556           0.676471           0.205882   \n",
       "1                0.574147     3.677966           0.508021           0.288770   \n",
       "2                0.996526     2.382883           0.562016           0.321705   \n",
       "3                0.801248     1.543103           0.400000           0.100000   \n",
       "4                0.719157     2.676471           0.500000           0.222222   \n",
       "\n",
       "   commonlinkratio_3  commonlinkratio_4  ...  is_news  lengthyLinkDomain  \\\n",
       "0           0.047059           0.023529  ...        0                  1   \n",
       "1           0.213904           0.144385  ...        0                  1   \n",
       "2           0.120155           0.042636  ...        0                  1   \n",
       "3           0.016667           0.000000  ...        0                  0   \n",
       "4           0.123457           0.043210  ...        0                  1   \n",
       "\n",
       "   linkwordscore  news_front_page  non_markup_alphanum_characters  \\\n",
       "0             24                0                            5424   \n",
       "1             40                0                            4973   \n",
       "2             55                0                            2240   \n",
       "3             24                0                            2737   \n",
       "4             14                0                           12032   \n",
       "\n",
       "   numberOfLinks  numwords_in_url  parametrizedLinkRatio  \\\n",
       "0            170                8               0.152941   \n",
       "1            187                9               0.181818   \n",
       "2            258               11               0.166667   \n",
       "3            120                5               0.041667   \n",
       "4            162               10               0.098765   \n",
       "\n",
       "   spelling_errors_ratio  label  \n",
       "0               0.079130      0  \n",
       "1               0.125448      1  \n",
       "2               0.057613      1  \n",
       "3               0.100858      1  \n",
       "4               0.082569      0  \n",
       "\n",
       "[5 rows x 27 columns]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ec3eacc4",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:16:33.450854Z",
     "start_time": "2021-09-17T06:16:33.444121Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    }
   ],
   "source": [
    "label = 'label'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "a225cdb6",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:56:06.463888Z",
     "start_time": "2021-09-17T06:16:34.936086Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Beginning AutoGluon training ...\n",
      "AutoGluon will save models to \"agModels-stumbleupon/\"\n",
      "AutoGluon Version:  0.2.1b20210716\n",
      "Train Data Rows:    7395\n",
      "Train Data Columns: 26\n",
      "Preprocessing data ...\n",
      "AutoGluon infers your prediction problem is: 'binary' (because only two unique label-values observed).\n",
      "\t2 unique label values:  [0, 1]\n",
      "\tIf 'binary' is not the correct problem_type, please manually specify the problem_type argument in fit() (You may specify problem_type as one of: ['binary', 'multiclass', 'regression'])\n",
      "Selected class <--> label mapping:  class 1 = 1, class 0 = 0\n",
      "Using Feature Generators to preprocess the data ...\n",
      "Fitting AutoMLPipelineFeatureGenerator...\n",
      "\tAvailable Memory:                    253965.42 MB\n",
      "\tTrain Data (Original)  Memory Usage: 22.47 MB (0.0% of available memory)\n",
      "\tInferring data type of each feature based on column values. Set feature_metadata_in to manually specify special dtypes of the features.\n",
      "\tStage 1 Generators:\n",
      "\t\tFitting AsTypeFeatureGenerator...\n",
      "\tStage 2 Generators:\n",
      "\t\tFitting FillNaFeatureGenerator...\n",
      "\tStage 3 Generators:\n",
      "\t\tFitting IdentityFeatureGenerator...\n",
      "\t\tFitting CategoryFeatureGenerator...\n",
      "\t\t\tFitting CategoryMemoryMinimizeFeatureGenerator...\n",
      "\t\tFitting TextSpecialFeatureGenerator...\n",
      "\t\t\tFitting BinnedFeatureGenerator...\n",
      "\t\t\tFitting DropDuplicatesFeatureGenerator...\n",
      "\t\tFitting TextNgramFeatureGenerator...\n",
      "\t\t\tFitting CountVectorizer for text features: ['boilerplate']\n",
      "\t\t\tCountVectorizer fit with vocabulary size = 10000\n",
      "\tStage 4 Generators:\n",
      "\t\tFitting DropUniqueFeatureGenerator...\n",
      "\tUseless Original Features (Count: 1): ['framebased']\n",
      "\t\tThese features carry no predictive signal and should be manually investigated.\n",
      "\t\tThis is typically a feature which has the same value for all rows.\n",
      "\t\tThese features do not need to be present at inference time.\n",
      "\tUnused Original Features (Count: 1): ['url']\n",
      "\t\tThese features were not used to generate any of the output features. Add a feature generator compatible with these features to utilize them.\n",
      "\t\tFeatures can also be unused if they carry very little information, such as being categorical but having almost entirely unique values or being duplicates of other features.\n",
      "\t\tThese features do not need to be present at inference time.\n",
      "\t\t('object', []) : 1 | ['url']\n",
      "\tTypes of features in original data (raw dtype, special dtypes):\n",
      "\t\t('float', [])        : 13 | ['alchemy_category_score', 'avglinksize', 'commonlinkratio_1', 'commonlinkratio_2', 'commonlinkratio_3', ...]\n",
      "\t\t('int', [])          :  9 | ['urlid', 'hasDomainLink', 'is_news', 'lengthyLinkDomain', 'linkwordscore', ...]\n",
      "\t\t('object', [])       :  1 | ['alchemy_category']\n",
      "\t\t('object', ['text']) :  1 | ['boilerplate']\n",
      "\tTypes of features in processed data (raw dtype, special dtypes):\n",
      "\t\t('category', [])                    :     1 | ['alchemy_category']\n",
      "\t\t('category', ['text_as_category'])  :     1 | ['boilerplate']\n",
      "\t\t('float', [])                       :    13 | ['alchemy_category_score', 'avglinksize', 'commonlinkratio_1', 'commonlinkratio_2', 'commonlinkratio_3', ...]\n",
      "\t\t('int', [])                         :     9 | ['urlid', 'hasDomainLink', 'is_news', 'lengthyLinkDomain', 'linkwordscore', ...]\n",
      "\t\t('int', ['binned', 'text_special']) :    26 | ['boilerplate.char_count', 'boilerplate.word_count', 'boilerplate.capital_ratio', 'boilerplate.lower_ratio', 'boilerplate.digit_ratio', ...]\n",
      "\t\t('int', ['text_ngram'])             : 10001 | ['__nlp__.00', '__nlp__.000', '__nlp__.01', '__nlp__.02', '__nlp__.03', ...]\n",
      "\t49.9s = Fit runtime\n",
      "\t24 features in original data used to generate 10051 features in processed data.\n",
      "\tTrain Data (Processed) Memory Usage: 149.42 MB (0.1% of available memory)\n",
      "Data preprocessing and feature engineering runtime = 52.66s ...\n",
      "AutoGluon will gauge predictive performance using evaluation metric: 'accuracy'\n",
      "\tTo change this, specify the eval_metric argument of fit()\n",
      "Automatically generating train/validation split with holdout_frac=0.1, Train Rows: 6655, Val Rows: 740\n",
      "Fitting 13 L1 models ...\n",
      "Fitting model: KNeighborsUnif ...\n",
      "\t0.5649\t = Validation accuracy score\n",
      "\t3.23s\t = Training runtime\n",
      "\t0.73s\t = Validation runtime\n",
      "Fitting model: KNeighborsDist ...\n",
      "\t0.5595\t = Validation accuracy score\n",
      "\t3.24s\t = Training runtime\n",
      "\t0.6s\t = Validation runtime\n",
      "Fitting model: LightGBMXT ...\n",
      "\t0.7851\t = Validation accuracy score\n",
      "\t358.15s\t = Training runtime\n",
      "\t0.21s\t = Validation runtime\n",
      "Fitting model: LightGBM ...\n",
      "\t0.7824\t = Validation accuracy score\n",
      "\t413.82s\t = Training runtime\n",
      "\t0.22s\t = Validation runtime\n",
      "Fitting model: RandomForestGini ...\n",
      "\t0.7743\t = Validation accuracy score\n",
      "\t18.22s\t = Training runtime\n",
      "\t0.27s\t = Validation runtime\n",
      "Fitting model: RandomForestEntr ...\n",
      "\t0.7784\t = Validation accuracy score\n",
      "\t17.52s\t = Training runtime\n",
      "\t0.29s\t = Validation runtime\n",
      "Fitting model: CatBoost ...\n",
      "\t0.7892\t = Validation accuracy score\n",
      "\t71.16s\t = Training runtime\n",
      "\t0.96s\t = Validation runtime\n",
      "Fitting model: ExtraTreesGini ...\n",
      "\t0.7824\t = Validation accuracy score\n",
      "\t20.11s\t = Training runtime\n",
      "\t0.31s\t = Validation runtime\n",
      "Fitting model: ExtraTreesEntr ...\n",
      "\t0.7824\t = Validation accuracy score\n",
      "\t19.41s\t = Training runtime\n",
      "\t0.35s\t = Validation runtime\n",
      "Fitting model: NeuralNetFastAI ...\n",
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: The NVIDIA driver on your system is too old (found version 10010). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver. (Triggered internally at  /pytorch/c10/cuda/CUDAFunctions.cpp:115.)\n",
      "  return torch._C._cuda_getDeviceCount() > 0\n",
      "No improvement since epoch 1: early stopping\n",
      "\t0.7622\t = Validation accuracy score\n",
      "\t269.69s\t = Training runtime\n",
      "\t14.79s\t = Validation runtime\n",
      "Fitting model: XGBoost ...\n",
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/xgboost/core.py:104: UserWarning: ntree_limit is deprecated, use `iteration_range` or model slicing instead.\n",
      "  UserWarning\n",
      "\t0.777\t = Validation accuracy score\n",
      "\t75.75s\t = Training runtime\n",
      "\t0.21s\t = Validation runtime\n",
      "Fitting model: NeuralNetMXNet ...\n",
      "\t0.6986\t = Validation accuracy score\n",
      "\t17.39s\t = Training runtime\n",
      "\t0.21s\t = Validation runtime\n",
      "Fitting model: LightGBMLarge ...\n",
      "\t0.7838\t = Validation accuracy score\n",
      "\t975.95s\t = Training runtime\n",
      "\t0.16s\t = Validation runtime\n",
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/xgboost/core.py:104: UserWarning: ntree_limit is deprecated, use `iteration_range` or model slicing instead.\n",
      "  UserWarning\n",
      "Fitting model: WeightedEnsemble_L2 ...\n",
      "\t0.8068\t = Validation accuracy score\n",
      "\t0.83s\t = Training runtime\n",
      "\t0.0s\t = Validation runtime\n",
      "AutoGluon training complete, total runtime = 2371.37s ...\n",
      "TabularPredictor saved. To load, use: predictor = TabularPredictor.load(\"agModels-stumbleupon/\")\n"
     ]
    }
   ],
   "source": [
    "save_path = f'agModels-{data_name}'  # specifies folder to store trained models\n",
    "predictor = TabularPredictor(label=label, path=save_path).fit(train_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "fa84c4eb",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:56:06.590999Z",
     "start_time": "2021-09-17T06:56:06.467316Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n",
      "Loaded data from: ../autox/data/stumbleupon/test.csv | Columns = 26 / 26 | Rows = 3171 -> 3171\n"
     ]
    }
   ],
   "source": [
    "test_data_nolab = TabularDataset(f'../autox/data/{data_name}/test.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "54cce4ce",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:57:32.061917Z",
     "start_time": "2021-09-17T06:56:06.593340Z"
    }
   },
   "outputs": [],
   "source": [
    "y_pred = predictor.predict(test_data_nolab)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ca6cc9bf",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:57:32.072494Z",
     "start_time": "2021-09-17T06:57:32.064668Z"
    },
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/caihengxing/anaconda3/envs/python37/lib/python3.7/site-packages/ipykernel/ipkernel.py:287: DeprecationWarning: `should_run_async` will not call `transform_cell` automatically in the future. Please pass the result to `transformed_cell` argument and any exception that happen during thetransform in `preprocessing_exc_tuple` in IPython 7.17 and above.\n",
      "  and should_run_async(code)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0       1\n",
       "1       0\n",
       "2       0\n",
       "3       0\n",
       "4       1\n",
       "       ..\n",
       "3166    1\n",
       "3167    1\n",
       "3168    1\n",
       "3169    1\n",
       "3170    1\n",
       "Name: label, Length: 3171, dtype: int64"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y_pred"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "240cd16c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:57:32.077204Z",
     "start_time": "2021-09-17T06:57:32.074388Z"
    }
   },
   "outputs": [],
   "source": [
    "id_ = ['urlid']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "b4fd354e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:57:32.086590Z",
     "start_time": "2021-09-17T06:57:32.079172Z"
    },
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "sub = test_data_nolab[id_].copy()\n",
    "sub[label] = list(y_pred.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "c59b336a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-09-17T06:57:32.100040Z",
     "start_time": "2021-09-17T06:57:32.088472Z"
    }
   },
   "outputs": [],
   "source": [
    "sub.to_csv(f\"./sub/autogluon_sub_{data_name}.csv\", index = False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c43926aa",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b54628e",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
